//确认支付
function sure_pay() {
    var kuaiDiFree = $('#integralInput').val();
    //是否使用积分支付
    if($('#jifen').is(':checked')){
    	var oldPoints = $('#old_points').text();
    	var newPoint = $('#l_newPoint').val();    //抵用积分数
    	
    	if(newPoint == null || newPoint == ''){
    		 alert("请输入要抵扣的积分数");return;
    	}else{
			if(newPoint % 20 != 0){
			   alert("每20积分抵扣1元，请输入20的倍数");return;
			}
		}
    	
    	if(newPoint > oldPoints) {
    		alert("您当前只有["+oldPoints+"]积分数可用");
    		return;
    	}
    }
    
    var r = confirm("确定支付?");
    if (r==false) {
        return;
    }

    layer.open({type: 2});
    sureToPay(kuaiDiFree,newPoint);
}

function sureToPay(price,newPoint) {
    var crkrdUuid = GetParpam("crkrdUuid");
    var userUuid = dataGet("userUuid");
    var openId = dataGet("openId");
    
    var dkFee;
    if(newPoint != undefined){
    	dkFee = (1/20) * newPoint;   //抵扣费用
    }else{
    	dkFee = 0;newPoint = 0;
    }
    
    var zfFee = price - dkFee;
    
    var data = "&crkrdUuid="+crkrdUuid+"&zfFee="+zfFee+"&totalFee="+price+"&syScore="+newPoint+"&dkFee="+dkFee
    	+"&userUuid="+userUuid+"&body="+"预约费用"+"&openId="+openId +"&attach=1";
    var url = urlfile + "pay/get/package/kuaidi";
    ajaxTool("post",data,url,
        function error(XMLHttpRequest, textStatus, errorThrown,fnErr){
            alert("error:" + data);
        },
        function success(data){
            if(!data.success) {
                alert(data.errMsg);
            }else{
                goToPay(data)
            }
        }
    );
}
